﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Buffalo.Administration.DAL;
using Buffalo.Administration.Enum;
using Buffalo.Lib.Common;

namespace Buffalo.Web.Areas.SMECommon.Controllers
{
    public class BaseController : Controller
    {
        protected ActionResult CheckPermission(string featureName)
        {
            bool IsLogInChecked = Util.ToSafeBool(new ConfigDAL().GetConfigValue("IsLogInChecked"));
            if (IsLogInChecked && !HttpContext.User.Identity.IsAuthenticated)
                return this.RedirectToAction("ReLogin", "Home");

            bool hasViewPermision = new PermissionDAL().HasPermission(GeneralVar.gLoggedUserName, featureName, enuPermissionType.View);
            if (hasViewPermision)
                return this.View();
            return null;
        }
    }
}